//引入express库（模块）
var express = require('express');


//实例化一个app对象
var app = express();

app.engine('html',require('express-art-template'));
app.set('views','./www');

var data = {
    list:[
        {name:"玫瑰花", price:100},
        {name:"郁金香", price:120},
        {name:"狗尾草", price:10}
    ]
}

//路由选择 '/'
app.get('/',(req,res)=>{
    res.render('index.html',data);
});

//路由选择 '/json'
app.get('/json',(req,res)=>{
    res.json({
        name:"小红",
        age: 18
    })
});

app.get('/list',(req,res)=>{
    res.send("have a good day!");
})

app.listen(8888,()=>{
    console.log("server 启动成功");
})